﻿using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace Ku.AppCore
{
    /// <summary>
    /// 消息
    /// </summary>
    public class MessageBoxUtil
    {
        /// <summary>
        /// 显示模态弹窗，可以只有一个确定按钮，也可以同时有确定和取消按钮。类似于一个API整合了 html 中：alert、confirm。
        /// </summary>
        /// <param name="messageBoxText"></param>
        /// <returns></returns>
        public static MessageBoxResult ShowModal(string message)
        {
            return System.Windows.MessageBox.Show(message);
        }
        /// <summary>
        /// 模态询问框
        /// </summary>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static bool ShowModalConfirm(string message, string title = "信息")
        {
            var messageBoxResult = System.Windows.MessageBox.Show(message, title, MessageBoxButton.OKCancel);
            if (messageBoxResult == MessageBoxResult.OK)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 显示消息提示框 在屏幕的右侧位置，然后渐隐消失。
        /// </summary>
        /// <param name="message"></param>
        public static void ShowToast(string message, ShowToastType toastType = ShowToastType.Info)
        {
            switch (toastType)
            {
                case ShowToastType.Info:
                    Growl.Info(message);
                    break;
                case ShowToastType.Success:
                    Growl.Success(message);
                    break;
                case ShowToastType.Warning:
                    Growl.Warning(message);
                    break;
                case ShowToastType.Error:
                    Growl.Error(message);
                    break;
                case ShowToastType.Fatal:
                    Growl.Fatal(message);
                    break;
                default:
                    Growl.Info(message);
                    break;
            }

        }

        public static void ShowToastGlobal(string message, ShowToastType toastType = ShowToastType.Info)
        {
            switch (toastType)
            {
                case ShowToastType.Info:
                    Growl.InfoGlobal(message);
                    break;
                case ShowToastType.Success:
                    Growl.SuccessGlobal(message);
                    break;
                case ShowToastType.Warning:
                    Growl.WarningGlobal(message);
                    break;
                case ShowToastType.Error:
                    Growl.ErrorGlobal(message);
                    break;
                case ShowToastType.Fatal:
                    Growl.FatalGlobal(message);
                    break;
                default:
                    Growl.InfoGlobal(message);
                    break;
            }

        }


        /// <summary>
        /// 清理
        /// </summary>
        public static void ClearToast()
        {

            Growl.Clear();
        }
        public static void ClearToastGlobal()
        {
            Growl.ClearGlobal();
        }
    }

    public enum ShowToastType
    {
        /// <summary>
        /// 信息
        /// </summary>
        Info,
        /// <summary>
        /// 成功
        /// </summary>
        Success,
        /// <summary>
        /// 警告
        /// </summary>
        Warning,
        /// <summary>
        /// 错误
        /// </summary>
        Error,
        /// <summary>
        /// 询问
        /// </summary>
        //Ask,
        /// <summary>
        /// 严重
        /// </summary>
        Fatal,
    }
}